package com.aiyige.page.publish.selectsuitablelearnage.adapter;

import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.aiyige.R;
import com.aiyige.page.publish.selectlearntarget.model.SelectLearnTargetItem;
import com.aiyige.page.publish.selectsuitablelearnage.model.SuitableLearnAgeItem;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.LinkedList;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by zhuyakun on 2017/11/9.
 */

public class SuitableLearnAgeAdapter extends BaseQuickAdapter<SuitableLearnAgeItem, SuitableLearnAgeAdapter.ViewHolder> {


    public SuitableLearnAgeAdapter() {
        super(R.layout.select_learn_age_item, new LinkedList<SuitableLearnAgeItem>());
    }

    @Override
    protected void convert(ViewHolder helper, SuitableLearnAgeItem item) {
        helper.bindData(item);
    }


    public class ViewHolder extends BaseViewHolder {
        @BindView(R.id.titleTv)
        TextView titleTv;
        @BindView(R.id.addIv)
        ImageView addIv;

        public ViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }

        public void bindData(SuitableLearnAgeItem item) {
            switch (item.getType()) {
                case SuitableLearnAgeItem.TYPE_ADD:
                    addIv.setVisibility(View.VISIBLE);
                    titleTv.setVisibility(View.GONE);
                    break;
                case SuitableLearnAgeItem.TYPE_NORMAL:
                    addIv.setVisibility(View.GONE);
                    titleTv.setVisibility(View.VISIBLE);
                    titleTv.setSelected(item.isSelected());
                    titleTv.setText(item.getTitle());
                    break;
            }

        }


    }
}
